package com.rentplant.controller;


import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.itemjudge;
import com.rentplant.Pojo.judgeinfo;
import com.rentplant.service.impl.itemJudgeServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController//让它知道这是controller
@RequestMapping("/itemJudge")
public class itemJudgeController {

    @Autowired
    private itemJudgeServiceImp itemjudgeserviceimo;


    //    生成物品评价
    @RequestMapping("/submititemjudge")
    public boolean itemJudge(@RequestBody JSONObject req){
        try {
            return itemjudgeserviceimo.itemJudge(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }


    //查询是否存在该订单的评价
    @RequestMapping("/selectOrderJudge")
    public List<itemjudge> selectOrderJudge(@RequestBody JSONObject req){
        try {
            return itemjudgeserviceimo.selectOrderJudge(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    //查找该物品的评论
    @RequestMapping("/selectJudgeByItemid")
    public List<judgeinfo> selectJudgeByItemid(@RequestBody JSONObject req){
        try {
            return itemjudgeserviceimo.selectJudgeByItemid(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    //查找不同等级
    @RequestMapping("/selectDifferJudge")
    public List<judgeinfo> selectDifferJudge(@RequestBody JSONObject req){
        try {
            return itemjudgeserviceimo.selectDifferJudge(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }


}
